﻿using System;
using System.Collections.Generic;
using System.Text;

namespace POSPlus.DatabaseOperations
{
	/// <summary>
	/// Base class for database operations.
	/// </summary>
	/// <remarks>
	/// This class has been depreciated: Extend the DatabaseObject for specific database information.
	/// </remarks>
	public abstract class DatabaseOperationExecutor
	{
		#region Properties
		public String CommandString { get; set; }
		public abstract Int32 RecordCount { get; }
		#endregion

		#region Members
		protected DatabaseConnectionManager _connectionManager;
		private string connectionString;
		#endregion

		#region Constructors
		public DatabaseOperationExecutor(String server, String user, String password, String database)
		{
			_connectionManager = new DatabaseConnectionManager(server, user, password, database);
		}

		public DatabaseOperationExecutor(string connectionString)
		{
			_connectionManager = new DatabaseConnectionManager(connectionString);
		}
		#endregion

		#region Methods
		public abstract void Execute();
		protected void Close()
		{
			_connectionManager.Close();
			_connectionManager.Connection.Dispose();
		}
		#endregion
	}
}
